﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using DTO;

namespace DAO
{
    public class DAO_User
    {
        public static object LayThongTinvaQuyenHan(User userDTO)
        {
            try
            {
                NHASACHDataContext dcNhaSach = new NHASACHDataContext();
                var vUser = from user in dcNhaSach.Users
                            join nGroup in dcNhaSach.Groups on user.MaNhom equals nGroup.MaNhom
                            join nMenu in dcNhaSach.Menus on user.MaNhom equals nMenu.Nhom
                            where user.Username == userDTO.Username
                            where user.Password == userDTO.Password
                            orderby nMenu.MaMenu
                            select new
                            {
                                user.Ten,
                                nMenu.TenMenu,
                                nMenu.Value,
                                
                            };
                return vUser;
            }
            catch (System.Exception ex)
            {
                string str = ex.Message;
                return null;
            }
        }
    }
}
